class ScreenController < ApplicationController
  
  include ScreenHelper
  layout 'screen'
  
  $pages = ['calendar', 'seminars', 'map']
  
  def index

     if session[:screenPage] == nil
       session[:screenPage] = 0
     end
    
    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @screen }
    end
  end
  
  
  def periodic_update
    
    puts "periodical update called"
    
    n = session[:screenPage]
    n = n + 1
    if n == $pages.length
      n = 0
    end
  
    
    session[:screenPage] = n
    
    puts "n is : " + n.to_s
    puts "page loaded : " + $pages[n]
    if $pages[n] == 'seminars'
      params[:main] = 0
      params[:show] = 2
      query_seminars
    elsif $pages[n] == 'map'
      params[:main] = 0
      params[:show] = 0
      query_room_events
    elsif $pages[n] == 'calendar'
      params[:main] = 0
      query_calendar_events
    else
      @test = $pages[n]
      render :partial => "/screen/templates/periodic_update"  
    end  
  end
  
end
